<?php

namespace backend\models;

use Yii;
use common\models\City;

/**
 * This is the model class for table "bulid_city".
 *
 * @property integer $id
 * @property string $name
 * @property integer $city_id
 * @property integer $sort
 */
class BuildCity extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
	public $province_id;
    public static function tableName()
    {
        return 'bulid_city';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['search_index','city_id'],'required'],
            [['city_id', 'sort', 'province_id'], 'integer'],
            [['name'], 'string', 'max' => 64],
            [['search_index'], 'match', 'pattern' => '/^[A-Z]{1,2}$/'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => Yii::t('app','Build City Name'),
            'city_id' => Yii::t('app','City'),
            'sort' =>  Yii::t('app','Sort'),     
            'province_id' => Yii::t('app','Province'),
            'search_index' => Yii::t('app','搜索首字母'),
            
        ];
    }
    public function getCityName(){
    	return $this->hasOne(City::className(), ['id'=>'city_id']);
    }
}
